import Vue from "vue";
import VueRouter from "vue-router";
import Err from "../views/404.vue";
import Home from "../views/Home.vue";
import Rofile from "../views/Rofile.vue";
import Contactus from "../views/Contactus.vue";
import Bsstory from "../views/Bsstory.vue";
import Babyknow from "../views/Babyknow.vue";
import Babycontent from "../components/general/babacontent";

Vue.use(VueRouter);

// const routes = [
//   {
//     path: "/",
//     name: "Home",
//     component: Home,
//     meta: { title: "笑彤彤" }
//   },
//   {
//     path: "/rofile",
//     component: Rofile,
//     meta: { title: "笑彤彤" }
//   },
//   {
//     path: "/contactus",
//     component: Contactus,
//     meta: { title: "笑彤彤" }
//   },
//   //Bsstory
//   {
//     path: "/bsstory",
//     component: Bsstory,
//     meta: { title: "笑彤彤" }
//   },
//   {
//     path: "*",
//     component: Err,
//     //meta: {title: '小木博客'}
//     //redirect: '/home'
//   }
// ];

const router = new VueRouter({
  // mode: "",
  routes: [
    {
      path: "/",
      name: "Home",
      component: Home,
      meta: { title: "笑彤彤" },
    },
    {
      path: "/rofile",
      component: Rofile,
      meta: { title: "笑彤彤" },
    },
    {
      path: "/contactus",
      component: Contactus,
      meta: { title: "笑彤彤" },
    },
    {
      path: "/bsstory",
      component: Bsstory,
      meta: { title: "笑彤彤" },
    },
    {
      path: "/babyknow",
      component: Babyknow,
      meta: { title: "笑彤彤" },
    },
    {
      path: "/babycontent",
      component: Babycontent,
      meta: { title: "笑彤彤" },
    },
    {
      path: "*",
      component: Err,
      //meta: {title: '小木博客'}
      //redirect: '/home'
    },
  ],
  // routes
});

router.beforeEach((to, from, next) => {
  /* 路由发生变化修改页面title */
  if (to.meta.title) {
    document.title = to.meta.title;
  }
  next();
});

export default router;
